#ifndef __Color_hpp__
#define __Color_hpp__

#include "ByteColor.hpp"

namespace ge {

//----------------------------------------------------------------------------//
// Color
//----------------------------------------------------------------------------//

class Color
{
 public:

     Color( void )
     {
     }

     Color( float _r, float _g, float _b, float _a = 1.0f ) : r( _r ), g( _g ), b( _b ), a( _a )
     {
     }

     Color( float _rgb, float _a = 1.0f ) : r( _rgb ), g( _rgb ), b( _rgb ), a( _a )
     {
     }

     Color( const Color& _color ) : r( _color.r ), g( _color.g ), b( _color.b ), a( _color.a )
     {
     }

     Color( const ByteColor& _color ) : r( _color.ToFloat( 0 ) ), g( _color.ToFloat( 1 ) ), b( _color.ToFloat( 2 ) ), a( _color.ToFloat( 3 ) ) 
     {
     }

     uint8 ToByte( uint _channel ) const
     {
          return static_cast< uint8 >( v[_channel] * 255.0f );
     }

     operator ByteColor ( void ) const
     {
          return ByteColor( ToByte( 0 ), ToByte( 1 ), ToByte( 2 ), ToByte( 3 ) );
     }

     Color& operator = ( const Color& _color ) 
     {
          return Set( _color );
     }

     Color& operator = ( const ByteColor& _color ) 
     {
          return Set( _color );
     }

     Color& Set( const Color& _color )
     {
          r = _color.r;
          g = _color.g;
          b = _color.b;
          a = _color.a;
          return *this;
     }

     Color& Set( const ByteColor& _color )
     {
          r = _color.ToFloat( 0 );
          g = _color.ToFloat( 1 );
          b = _color.ToFloat( 2 );
          a = _color.ToFloat( 3 );
          return *this;
     }

     Color& Set( float _r, float _g, float _b, float _a = 1.0f )
     {
          r = _r;
          g = _g;
          b = _b;
          a = _a;
          return *this;
     }

     static const Color Black;

 public:

     union
     {
          struct{ float r, g, b, a; };
          float v[4];
     };
};

} // namespace ge

#endif//__Color_hpp__
